<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="./pages/styles/style2.css" />
<title>Jobs</title>
</head>
<body>
	<jsp:directive.include file="Header.jsp" />
	<jsp:directive.include file="Navigation.jsp" />

	<div class="content">
		<div class="content-header">
			<h1>
				Jobs <img src="./pages/images/logo.png" align="right" width="130"
					height="40">
			</h1>
		</div>
		<c:choose>
			<c:when test="${empty jobList}">
				<div class="content-tag">
					<h3>No available jobs!</h3>
				</div>
			</c:when>
			<c:otherwise>
				<c:forEach var="job" items="${jobList}">
					<c:choose>
						<c:when test="${role == 'viewer' }">
							<c:if test="${job.opened and job.approved }">
								<div class="content-tag">
									<div class="content-tag-header">
										<h2>${job.title}</h2>
									</div>
									<ul>
										<li><label>Title:</label> ${job.title}</li>
										<li><label>Number of candidates:</label>
											${job.maxCandidates }</li>
										<li><label>Owner:</label> ${job.proposer.firstName }
											${job.proposer.lastName }</li>
										<li><label>Opened:</label> ${job.opened }</li>
										<li><label>Approved:</label> ${job.approved }</li>
										<li><label>Deadline:</label> ${job.deadLine }</li>
										<li><h3>Description</h3>
											<ul>
												<li><label>Department:</label>
													${job.description.department.name }</li>
												<li><label>Project:</label> ${job.description.project }</li>
												<li><label>Requirements:</label>
													${job.description.requirements }</li>
												<li><label>Responsabilities:</label>
													${job.description.responsabilities }</li>
											</ul></li>
									</ul>
								</div>
							</c:if>
						</c:when>
						<c:otherwise>
							<form action="./ShowJobs" method="post">
								<div class="content-tag">
									<div class="content-tag-header">
										<table>
											<tr>
												<td>
													<h2>${job.title}</h2>
												</td>
												<td><input type="hidden" name="jobId"
													value="${job.id }"> <input class="button"
													type="submit" name="viewrecommended"
													value="View Recommended Candidates"> <input
													class="button" type="submit" name="update" value="Update">
													<input class="button" type="submit" name="delete"
													value="Delete"></td>
											</tr>
										</table>
									</div>
									<ul>
										<li><label>Title:</label> ${job.title}</li>
										<li><label>Number of candidates:</label>
											${job.maxCandidates }</li>
										<li><label>Owner:</label> ${job.proposer.firstName }
											${job.proposer.lastName }</li>
										<li><label>Opened:</label> ${job.opened }</li>
										<li><label>Approved:</label> ${job.approved }</li>
										<li><label>Deadline:</label> ${job.deadLine }</li>
										<li><h3>Description</h3>
											<ul>
												<li><label>Department:</label>
													${job.description.department.name }</li>
												<li><label>Project:</label> ${job.description.project }</li>
												<li><label>Requirements:</label>
													${job.description.requirements }</li>
												<li><label>Responsabilities:</label>
													${job.description.responsabilities }</li>
											</ul></li>
										<li>
											<h3>Comments</h3>
											<div class="comment-area">
												<table>
													<tr>
														<td><textarea type="text" name="commentArea"
																placeholder="Enter  your  comment!"></textarea></td>
													</tr>
													<tr>
														<td><input type="submit" name="addComment"
															class="button" value="Add Comment" /></td>
													</tr>
												</table>
											</div> <c:choose>
												<c:when test="${empty job.comments }">
													<div class="comment-tag">
														<h4>No comments</h4>
													</div>
												</c:when>
												<c:otherwise>
													<c:forEach var="comment" items="${job.comments}">
														<div class="comment-tag">
															<ul>
																<li><label> Date: ${comment.date } </label></li>
															</ul>
															<ul>
																<li><label> User: ${comment.user.firstName }
																		${comment.user.lastName } </label></li>
															</ul>
															<ul>
																<li><label> Text : ${comment.content } </label></li>
															</ul>
														</div>
													</c:forEach>
												</c:otherwise>
											</c:choose>
										</li>
									</ul>
								</div>
							</form>
						</c:otherwise>
					</c:choose>
				</c:forEach>
			</c:otherwise>
		</c:choose>
	</div>

</body>
</html>